
#ifndef TEXT_PARSER_
#define TEXT_PARSER_

#include "Global.h"
#include <fstream>

class CTextParser
{
private:
    std::ifstream pParserFile; // handle of parsered file
	short nRecordNum;		//record number
	char cRecordHead;		//record head char

public:

    /* Open the File, get the record count */
	CTextParser(const char * stFileName, const char cHeadFlag);
    /* Close the file */
	~CTextParser();

    inline char RecordHead() {return cRecordHead;}

	short GetRecordNum();

    /* find the next place where a record begins */
	bool FindRecordHead(); 

	void GotoNextLine();	//goto next line

	bool GetWholeLine( char * stString ); //get a line

	void GotoFileHead ();		//goto file head

    /* read a string from the current line of the file */
	void ReadString ( char * stString ); 

    /* read a integer from the current line of the file */
	void ReadInteger ( short * nInt);

    /* read the next subString from the stString */
 	static void ReadSubString( char * stString, short * nIndexInLine,
                               char * stSubString );

	static bool ReadWholeTextFile( const char * stFileName ,
                                   char * stBuffer);

};
#endif
